import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PayAppVo, PayAppForm, PayAppQuery } from '@/api/pay/app/types';

/**
 * 查询支付应用列表
 * @param query
 * @returns {*}
 */

export const listPayApp = (query?: PayAppQuery): AxiosPromise<PayAppVo[]> => {
  return request({
    url: '/lawyer/payApp/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询支付应用详细
 * @param appId
 */
export const getPayApp = (appId: string | number): AxiosPromise<PayAppVo> => {
  return request({
    url: '/lawyer/payApp/' + appId,
    method: 'get'
  });
};

/**
 * 新增支付应用
 * @param data
 */
export const addPayApp = (data: PayAppForm) => {
  return request({
    url: '/lawyer/payApp/savePayApp',
    method: 'post',
    data: data
  });
};

/**
 * 修改支付应用
 * @param data
 */
export const updatePayApp = (data: PayAppForm) => {
  return request({
    url: '/lawyer/payApp/updatePayApp',
    method: 'post',
    data: data
  });
};

/**
 * 删除支付应用
 * @param appId
 */
export const delPayApp = (appId: string | number | Array<string | number>) => {
  return request({
    url: '/lawyer/payApp/removePayApp/' + appId,
    method: 'delete'
  });
};

export const activePayApp = (appId: string | number) => {
  const data = {
    appId
  };
  return request({
    url: '/lawyer/payApp/activePayApp',
    method: 'post',
    data: data
  });
};

export const inactivePayApp = (appId: string | number) => {
  const data = {
    appId
  };
  return request({
    url: '/lawyer/payApp/inactivePayApp',
    method: 'post',
    data: data
  });
};
